package com.kuaimacode.kframework.api.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.kuaimacode.kframework.common.Constant;
import com.kuaimacode.kframework.mybatis.mapper.user.CardBINMapper;
import com.kuaimacode.kframework.mybatis.models.user.CardBIN;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class CardBINService extends ServiceImpl<CardBINMapper, CardBIN> {


    CardBIN findByCardNo(String cardNo){

        for(int i=3;i<=12;i++){
            QueryWrapper queryWrapper = new QueryWrapper();
            queryWrapper.likeRight("bin",cardNo.substring(0,i));
            int count = baseMapper.selectCount(queryWrapper);
            if(count==1){
                return baseMapper.selectOne(queryWrapper);
            }else if(count==0){

                return null;
            }

        }
        return null;

    }


}